package com.tuozixuan.api;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

import java.net.MalformedURLException;
import java.nio.ByteBuffer;

@Api(tags = "WebFlux Api", description = "WebFlux信息接口")
@RequestMapping("/webFluxDemo")
public interface WebFluxDemoApi {

    @ApiOperation(value="根据ID获取用户信息", notes="根据ID获取用户信息")
    @GetMapping(value = "/getIntegerFlux", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
    Flux<Integer> getIntegerFlux();

    @ApiOperation(value = "獲取單個字符串", notes = "獲取單個字符串")
    @GetMapping("/getString")
    Mono<String> getString();

    @ApiOperation(value = "獲取多個字符串", notes = "獲取多個字符串")
    @GetMapping("/getStringFlux")
    Flux<String> getStringFlux();

    @ApiOperation(value = "獲取文本事件流", notes = "獲取文本事件流")
    @GetMapping(value = "/getTextEventStream", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
    Flux<String> getTextEventStream();

    @ApiOperation(value = "獲取字節數組流", notes = "獲取字節數組流")
    @GetMapping(value = "/getByteArrayStream", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
    Flux<byte[]> getByteArrayStream();

    @ApiOperation(value = "獲取字節緩衝流", notes = "獲取字節緩衝流")
    @GetMapping(value = "/getByteBufferStream", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
    Flux<ByteBuffer> getByteBufferStream();

    @ApiOperation(value = "獲取音频字節數組流", notes = "獲取音频字節數組流")
    @GetMapping(value = "/getAudioStream", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
    Flux<byte[]> getAudioStream() throws MalformedURLException;

    @ApiOperation(value = "请求其他接口獲取音频字節數組流", notes = "请求其他接口獲取音频字節數組流")
    @GetMapping(value = "/getRequestAudioStream", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
    Flux<byte[]> getRequestAudioStream() throws MalformedURLException;

    @ApiOperation(value = "獲取字節數組流", notes = "獲取字節數組流", produces = "application/octet-stream")
    @GetMapping(value = "/getByteArrayOctetStream", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
    Flux<byte[]> getByteArrayOctetStream();

    @ApiOperation(value = "獲取音频字節數組流", notes = "獲取音频字節數組流", produces = "application/octet-stream")
    @GetMapping(value = "/getAudioOctetStream", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
    Flux<byte[]> getAudioOctetStream() throws MalformedURLException;
}
